
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>运算符 · 李德龙杰的Python</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="李龙杰老师">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-flexible-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-lou/lou.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="输入、输出.html" />
    

    </head>
    <body>
         
<div class="donate-modal modal">
  <div class="modal-header">
    <div>
      <span>
        <img
          id="modal-avatar"
          class="modal-avatar"
          src="https://img-blog.csdnimg.cn/5b13125ceaf34013b121c91402d1a071.jpeg"
        />
      </span>
      <span id="nickname"> 李龙杰老师 </span>
      <p class="modal-close close" onclick="closeDonateModal()">×</p>
    </div>
    <div class="message">
      <div class="tip">
        <i></i>
        <span>随意打赏，但不要超过一顿早餐钱！</span>
      </div>
    </div>
  </div>
  <div class="modal-content">
    <div class="modal-pay-way">
      <div id="wxpay" onclick="showDonateImg(0)">
        <input
          type="radio"
          name="pay-way"
          value="wxpay"
          class="zs-type"
          checked="checked"
        />
        <span>
          <img
            id="wxpay-logo"
            src=""
          />
        </span>
      </div>
      <div id="alipay" onclick="showDonateImg(1)">
        <input type="radio" name="pay-way" value="alipay" class="zs-type" />
        <span>
          <img
            id="alipay-logo"
            src=""
          />
        </span>
      </div>
    </div>
    <div class="modal-pay-qrcode">
      <img id="wxpay-code" src="https://img-blog.csdnimg.cn/5187bec6d38144e8b2c3382030271c5f.png" />
      <img
        id="alipay-code"
        src="https://img.alicdn.com/imgextra/i2/1670499728/O1CN01HdkbmL2LjTjnA70LN_!!1670499728.png"
        hidden
      />
    </div>
  </div>
</div>
<div class="mask"></div>


<div class="book">
  <div class="header-inner">
    <!-- LOGO -->
    <div class="logo"></div>
    <span class="title"></span>

    <!-- Search -->
    
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>


    <!-- Nav -->
    <ul class="header-nav">
      <li>
        <a href="https://shop409343045.taobao.com/shop/view_shop.htm?spm=a230r.1.14.19.534413e8q3O6hN&user_number_id=1670499728" target="_blank">机器人淘宝店</a>
      </li>
    </ul>
  </div>

  <div class="book-summary">
    <div class="book-summary-title">文档目录</div>
     
    <nav role="navigation">


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Python
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../1_Python基础知识.html">
            
                <a href="../1_Python基础知识.html">
            
                    
                    1_Python基础知识
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" >
            
                <span>
            
                    
                    1.基础知识
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1.1" data-path="第一个python程序.html">
            
                <a href="第一个python程序.html">
            
                    
                    第一个python程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.2" data-path="注释.html">
            
                <a href="注释.html">
            
                    
                    注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.3" data-path="常量、变量.html">
            
                <a href="常量、变量.html">
            
                    
                    常量、变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.4" data-path="数据类型.html">
            
                <a href="数据类型.html">
            
                    
                    数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.5" data-path="标识符和关键字.html">
            
                <a href="标识符和关键字.html">
            
                    
                    标识符和关键字
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.1.6" data-path="输入、输出.html">
            
                <a href="输入、输出.html">
            
                    
                    输入、输出
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.1.7" data-path="运算符.html">
            
                <a href="运算符.html">
            
                    
                    运算符
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>

</nav>
     
  </div>

  <!-- Content nav -->
  <div class="book-anchor">
    <div class="book-anchor-title"></div>

    <div class="book-anchor-body"></div>
  </div>

  <div class="book-body">
    
    <div class="body-inner">
       

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >运算符</a>
    </h1>
</div>



      <div class="page-wrapper" tabindex="-1" role="main">
        <div class="page-inner">
          
<div id="book-search-results">
    <div class="search-noresults">
    
<div id="book-search-results">
    <div class="search-noresults">
    
          <section class="normal markdown-section">
             <h1 id="&#x8FD0;&#x7B97;&#x7B26;">&#x8FD0;&#x7B97;&#x7B26;</h1>
<h1 id="1&#x3001;&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;">1&#x3001;&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x7B26;</h1>
<p>&#x4E0B;&#x9762;&#x4EE5;<code>a=10 ,b=20</code>&#x4E3A;&#x4F8B;&#x8FDB;&#x884C;&#x8BA1;&#x7B97;</p>
<table>
<thead>
<tr>
<th style="text-align:left">&#x8FD0;&#x7B97;&#x7B26;</th>
<th style="text-align:left">&#x63CF;&#x8FF0;</th>
<th style="text-align:left">&#x5B9E;&#x4F8B;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>+</code></td>
<td style="text-align:left">&#x52A0;</td>
<td style="text-align:left">&#x4E24;&#x4E2A;&#x5BF9;&#x8C61;&#x76F8;&#x52A0; <code>a + b</code> &#x8F93;&#x51FA;&#x7ED3;&#x679C;<code>30</code></td>
</tr>
<tr>
<td style="text-align:left"><code>-</code></td>
<td style="text-align:left">&#x51CF;</td>
<td style="text-align:left">&#x5F97;&#x5230;&#x8D1F;&#x6570;&#x6216;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x51CF;&#x53BB;&#x53E6;&#x4E00;&#x4E2A;&#x6570;<code>a - b</code>&#x8F93;&#x51FA;&#x7ED3;&#x679C;<code>-10</code></td>
</tr>
<tr>
<td style="text-align:left"><code>*</code></td>
<td style="text-align:left">&#x4E58;</td>
<td style="text-align:left">&#x4E24;&#x4E2A;&#x6570;&#x76F8;&#x4E58;&#x6216;&#x662F;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x88AB;&#x91CD;&#x590D;&#x82E5;&#x5E72;&#x6B21;&#x7684;&#x5B57;&#x7B26;&#x4E32; <code>a * b</code>&#x8F93;&#x51FA;&#x7ED3;&#x679C;<code>200</code></td>
</tr>
<tr>
<td style="text-align:left"><code>/</code></td>
<td style="text-align:left">&#x9664;</td>
<td style="text-align:left"><code>b / a</code> &#x8F93;&#x51FA;&#x7ED3;&#x679C;<code>2</code></td>
</tr>
<tr>
<td style="text-align:left"><code>//</code></td>
<td style="text-align:left">&#x53D6;&#x6574;&#x9664;</td>
<td style="text-align:left">&#x8FD4;&#x56DE;&#x5546;&#x7684;&#x6574;&#x6570;&#x90E8;&#x5206; <code>9//2</code>&#x8F93;&#x51FA;&#x7ED3;&#x679C;<code>4</code> , <code>9.0//2.0</code>&#x8F93;&#x51FA;&#x7ED3;&#x679C;<code>4.0</code></td>
</tr>
<tr>
<td style="text-align:left"><code>%</code></td>
<td style="text-align:left">&#x53D6;&#x4F59;</td>
<td style="text-align:left">&#x8FD4;&#x56DE;&#x9664;&#x6CD5;&#x7684;&#x4F59;&#x6570; <code>b % a</code>&#x8F93;&#x51FA;&#x7ED3;&#x679C;<code>0</code></td>
</tr>
<tr>
<td style="text-align:left"><code>**</code></td>
<td style="text-align:left">&#x6307;&#x6570;</td>
<td style="text-align:left"><code>2**3</code> &#x4E3A;<code>2</code>&#x7684;<code>3</code>&#x6B21;&#x65B9;&#xFF0C; &#x8F93;&#x51FA;&#x7ED3;&#x679C; <code>8</code></td>
</tr>
</tbody>
</table>
<h1 id="2&#x3001;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;">2&#x3001;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</h1>
<table>
<thead>
<tr>
<th style="text-align:left">&#x8FD0;&#x7B97;&#x7B26;</th>
<th style="text-align:left">&#x63CF;&#x8FF0;</th>
<th style="text-align:left">&#x5B9E;&#x4F8B;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>=</code></td>
<td style="text-align:left">&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</td>
<td style="text-align:left">&#x628A;<code>=</code> &#x53F7;&#x53F3;&#x8FB9;&#x7684;&#x7ED3;&#x679C; &#x8D4B;&#x7ED9; &#x5DE6;&#x8FB9;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x5982; <code>num = 1 + 2 * 3</code>&#xFF0C;&#x7ED3;&#x679C;<code>num</code>&#x7684;&#x503C;&#x4E3A;<code>7</code></td>
</tr>
</tbody>
</table>
<h1 id="3&#x3001;&#x590D;&#x5408;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;">3&#x3001;&#x590D;&#x5408;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</h1>
<table>
<thead>
<tr>
<th style="text-align:left">&#x8FD0;&#x7B97;&#x7B26;</th>
<th style="text-align:left">&#x63CF;&#x8FF0;</th>
<th style="text-align:left">&#x5B9E;&#x4F8B;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>+=</code></td>
<td style="text-align:left">&#x52A0;&#x6CD5;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</td>
<td style="text-align:left"><code>c += a</code> &#x7B49;&#x6548;&#x4E8E;<code>c = c + a</code></td>
</tr>
<tr>
<td style="text-align:left"><code>-=</code></td>
<td style="text-align:left">&#x51CF;&#x6CD5;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</td>
<td style="text-align:left"><code>c -= a</code> &#x7B49;&#x6548;&#x4E8E;<code>c = c - a</code></td>
</tr>
<tr>
<td style="text-align:left"><code>*=</code></td>
<td style="text-align:left">&#x4E58;&#x6CD5;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</td>
<td style="text-align:left"><code>c *= a</code>&#x7B49;&#x6548;&#x4E8E;<code>c = c * a</code></td>
</tr>
<tr>
<td style="text-align:left"><code>/=</code></td>
<td style="text-align:left">&#x9664;&#x6CD5;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</td>
<td style="text-align:left"><code>c /= a</code>&#x7B49;&#x6548;&#x4E8E;<code>c = c / a</code></td>
</tr>
<tr>
<td style="text-align:left"><code>%=</code></td>
<td style="text-align:left">&#x53D6;&#x6A21;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</td>
<td style="text-align:left"><code>c %= a</code>&#x7B49;&#x6548;&#x4E8E;<code>c = c % a</code></td>
</tr>
<tr>
<td style="text-align:left"><code>**=</code></td>
<td style="text-align:left">&#x5E42;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</td>
<td style="text-align:left"><code>c **= a</code> &#x7B49;&#x6548;&#x4E8E;<code>c = c ** a</code></td>
</tr>
<tr>
<td style="text-align:left"><code>//=</code></td>
<td style="text-align:left">&#x53D6;&#x6574;&#x9664;&#x8D4B;&#x503C;&#x8FD0;&#x7B97;&#x7B26;</td>
<td style="text-align:left"><code>c //= a</code>&#x7B49;&#x6548;&#x4E8E; <code>c = c // a</code></td>
</tr>
</tbody>
</table>
 
          </section>
          
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>
 
          <div class="book-footer">
            
            <div class="donate">
              <div>『 赠人玫瑰 🌹 手有余香 』</div>
              <button class="donate-btn" onclick="showModal()">赞赏</button>
            </div>
             
            <div class="copyright"></div>
            
          </div>
          
        </div>
      </div>
      
    </div>

     
    <a
      href="输入、输出.html"
      class="
        navigation navigation-prev
        navigation-unique
      "
      aria-label="Previous page: 输入、输出"
    >
      <i class="fa fa-angle-left"></i>
    </a>
       
  </div>
  <script>
    function showModal() {
      document.getElementsByClassName("mask")[0].style.display = "block";
      document.getElementsByClassName("donate-modal")[0].style.display =
        "block";
    }
    // 切换赞赏码
    function showDonateImg(num) {
      let alipay = "";
      let wxpay = ""
      if(num){
        wxpay = "hidden"
      }else{
        alipay = "hidden"
      }
      document.getElementById("wxpay-code").hidden = wxpay;
      document.getElementById("alipay-code").hidden = alipay;
      document.getElementsByName("pay-way")[num].checked = "checked";
    }

    // 关闭赞赏框
    function closeDonateModal() {
      document.getElementsByClassName("mask")[0].style.display = "none";
      document.getElementsByClassName("donate-modal")[0].style.display = "none";
    }

    var gitbook = gitbook || [];
    gitbook.push(function () {
      gitbook.page.hasChanged({"page":{"title":"运算符","level":"1.2.1.7","depth":3,"previous":{"title":"输入、输出","level":"1.2.1.6","depth":3,"path":"1_Python基础知识/1.基础知识/输入、输出.md","ref":"1_Python基础知识/1.基础知识/输入、输出.md","articles":[]},"dir":"ltr"},"config":{"plugins":["expandable-chapters","search-pro","code","back-to-top-button","flexible-alerts","highlight","splitter","sharing","theme-lou"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"splitter":{},"search-pro":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":true},"theme-lou":{"hide-elements":[".summary .gitbook-link",".summary .divider"],"color":"#FF4848","book-anchor-title":"本篇章节：","copyright":{"author":"李德龙杰"},"forbidCopy":false,"logo":"static/logo.png","book-summary-title":"目 录","search-placeholder":"输入关键字查找","copyrightLogo":"assets/copyright.png","favicon":"static/favicon.png"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"back-to-top-button":{},"flexible-alerts":{"danger":{"className":"danger","icon":"fa fa-ban","label":"Attention"},"note":{"className":"info","icon":"fa fa-info-circle","label":"Note"},"style":"callout","tip":{"className":"tip","icon":"fa fa-lightbulb-o","label":"Tip"},"warning":{"className":"warning","icon":"fa fa-exclamation-triangle","label":"Warning"}},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"李龙杰老师","lang":"zh-cn","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"themeLou":{"nav":[{"target":"_blank","url":"https://shop409343045.taobao.com/shop/view_shop.htm?spm=a230r.1.14.19.534413e8q3O6hN&user_number_id=1670499728","name":"机器人淘宝店"}],"footer":{"donate":{"button":"捐赠","avatar":"https://img-blog.csdnimg.cn/5b13125ceaf34013b121c91402d1a071.jpeg","nickname":"李龙杰老师","message":"随意打赏，但不要超过一顿早餐钱！","text":"『 赠人玫瑰 🌹 手有余香 』","wxpay":"https://img-blog.csdnimg.cn/5187bec6d38144e8b2c3382030271c5f.png","alipay":"https://img.alicdn.com/imgextra/i2/1670499728/O1CN01HdkbmL2LjTjnA70LN_!!1670499728.png"},"copyright":true}}},"title":"李德龙杰的Python","gitbook":"*"},"file":{"path":"1_Python基础知识/1.基础知识/运算符.md","mtime":"2023-02-07T06:30:27.752Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-02-07T06:59:44.160Z"},"basePath":"../..","book":{"language":""}});
    });
  </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-flexible-alerts/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-lou/lou.js"></script>
        
    

    </body>
</html>

